%include
:- lib(ic).

testTriangleCategory(OState, Arg, Result, NState) :-
	% Domains
	[OsideA] :: -32768 .. 32767,
	[NsideA] :: -32768 .. 32767,
	[OsideB] :: -32768 .. 32767,
	[NsideB] :: -32768 .. 32767,
	[OsideC] :: -32768 .. 32767,
	[NsideC] :: -32768 .. 32767,
	% Constraints
	OState = [OsideA, OsideB, OsideC],
	NState = [NsideA, NsideB, NsideC],
	triangleCategory(OState, Arg, Result, NState),
	% Solving
	indomain(OsideA),
	indomain(NsideA),
	indomain(OsideB),
	indomain(NsideB),
	indomain(OsideC),
	indomain(NsideC),
	locate([OsideA, OsideB, OsideC, NsideA, NsideB, NsideC], 0.1).

triangleCategory([OsideA, OsideB, OsideC], [], Result, [NsideA, NsideB, NsideC]) :-
	% Invariants
	OsideA + OsideB #> OsideC , 
OsideB + OsideC #> OsideA , 
OsideA + OsideC #> OsideB,
	% Precondition
	% Postcondition
	OsideA #= OsideB,
	OsideB #= OsideC,
	Result = "Equilateral" , 
NsideA #= OsideA , 
NsideB #= OsideB , 
NsideC #= OsideC,
	% Invariants
	NsideA + NsideB #> NsideC , 
NsideB + NsideC #> NsideA , 
NsideA + NsideC #> NsideB.

triangleCategory([OsideA, OsideB, OsideC], [], Result, [NsideA, NsideB, NsideC]) :-
	% Invariants
	OsideA + OsideB #> OsideC , 
OsideB + OsideC #> OsideA , 
OsideA + OsideC #> OsideB,
	% Precondition
	% Postcondition
	OsideA #= OsideB,
	neg(OsideB #= OsideC),
	Result = "Isosceles" , 
NsideA #= OsideA , 
NsideB #= OsideB , 
NsideC #= OsideC,
	% Invariants
	NsideA + NsideB #> NsideC , 
NsideB + NsideC #> NsideA , 
NsideA + NsideC #> NsideB.

triangleCategory([OsideA, OsideB, OsideC], [], Result, [NsideA, NsideB, NsideC]) :-
	% Invariants
	OsideA + OsideB #> OsideC , 
OsideB + OsideC #> OsideA , 
OsideA + OsideC #> OsideB,
	% Precondition
	% Postcondition
	neg(OsideA #= OsideB),
	OsideA #= OsideC,
	Result = "Isosceles" , 
NsideA #= OsideA , 
NsideB #= OsideB , 
NsideC #= OsideC,
	% Invariants
	NsideA + NsideB #> NsideC , 
NsideB + NsideC #> NsideA , 
NsideA + NsideC #> NsideB.

triangleCategory([OsideA, OsideB, OsideC], [], Result, [NsideA, NsideB, NsideC]) :-
	% Invariants
	OsideA + OsideB #> OsideC , 
OsideB + OsideC #> OsideA , 
OsideA + OsideC #> OsideB,
	% Precondition
	% Postcondition
	neg(OsideA #= OsideB),
	neg(OsideA #= OsideC),
	OsideB #= OsideC,
	Result = "Isosceles" , 
NsideA #= OsideA , 
NsideB #= OsideB , 
NsideC #= OsideC,
	% Invariants
	NsideA + NsideB #> NsideC , 
NsideB + NsideC #> NsideA , 
NsideA + NsideC #> NsideB.

triangleCategory([OsideA, OsideB, OsideC], [], Result, [NsideA, NsideB, NsideC]) :-
	% Invariants
	OsideA + OsideB #> OsideC , 
OsideB + OsideC #> OsideA , 
OsideA + OsideC #> OsideB,
	% Precondition
	% Postcondition
	neg(OsideA #= OsideB),
	neg(OsideA #= OsideC),
	neg(OsideB #= OsideC),
	Result = "Scalene" , 
NsideA #= OsideA , 
NsideB #= OsideB , 
NsideC #= OsideC,
	% Invariants
	NsideA + NsideB #> NsideC , 
NsideB + NsideC #> NsideA , 
NsideA + NsideC #> NsideB.
